package com.imooc.pojo;

import com.baomidou.mybatisplus.annotation.*;
import org.springframework.beans.BeanUtils;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;

import java.math.BigDecimal;
import java.io.Serializable;
import java.util.Date;
import lombok.Data;
import lombok.ToString;

/**
 * 商品规格 每一件商品都有不同的规格，不同的规格又有不同的价格和优惠力度，规格表为此设计
 * 
 * @author yukangkang
 * @email 1304473884@qq.com
 * @date 2021-01-16 21:20:11
 */
@Data
@ToString
@TableName("items_spec")
public class ItemsSpec implements Serializable {
	private static final long serialVersionUID = 1L;

		/**
		 * 商品规格id
		 */
		@TableId(value = ID, type = IdType.AUTO)
		private String id;
		/**
		 * 商品外键id
		 */
		@TableField(ITEM_ID)
		private String itemId;
		/**
		 * 规格名称
		 */
		@TableField(NAME)
		private String name;
		/**
		 * 库存
		 */
		@TableField(STOCK)
		private Integer stock;
		/**
		 * 折扣力度
		 */
		@TableField(DISCOUNTS)
		private BigDecimal discounts;
		/**
		 * 优惠价
		 */
		@TableField(PRICE_DISCOUNT)
		private Integer priceDiscount;
		/**
		 * 原价
		 */
		@TableField(PRICE_NORMAL)
		private Integer priceNormal;
		/**
		 * 创建时间
		 */
		@TableField(CREATED_TIME)
		private Date createdTime;
		/**
		 * 更新时间
		 */
		@TableField(UPDATED_TIME)
		private Date updatedTime;




	public final static String ID =  "`id`";
	public final static String ITEM_ID =  "`item_id`";
	public final static String NAME =  "`name`";
	public final static String STOCK =  "`stock`";
	public final static String DISCOUNTS =  "`discounts`";
	public final static String PRICE_DISCOUNT =  "`price_discount`";
	public final static String PRICE_NORMAL =  "`price_normal`";
	public final static String CREATED_TIME =  "`created_time`";
	public final static String UPDATED_TIME =  "`updated_time`";


	public final static String ID_COMMENT =  "商品规格id";
	public final static String ITEM_ID_COMMENT =  "商品外键id";
	public final static String NAME_COMMENT =  "规格名称";
	public final static String STOCK_COMMENT =  "库存";
	public final static String DISCOUNTS_COMMENT =  "折扣力度";
	public final static String PRICE_DISCOUNT_COMMENT =  "优惠价";
	public final static String PRICE_NORMAL_COMMENT =  "原价";
	public final static String CREATED_TIME_COMMENT =  "创建时间";
	public final static String UPDATED_TIME_COMMENT =  "更新时间";


	public static ItemsSpec of(Object obj) {
		ItemsSpec e = new ItemsSpec();
		BeanUtils.copyProperties(obj, e);
		return e;
	}

	public static QueryWrapper<ItemsSpec> queryWrapper(Object obj) {
		return new QueryWrapper<>(of(obj));
	}



}
